import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from "path"


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  base: "./",
  //服务器设置
  server: {
    host: "0.0.0.0",
    port: 4000,
    open: false,
    //反向代理
    proxy: {
      '/api': {
        target: `http://localhost:3000/`,
        changeOrigin: false,
        // rewrite: path => path.replace(/^\/api/, '')
      },
      '/document': {
        target: `http://localhost:3000/`,
        changeOrigin: false,
      },
      '/news': {
        target: `http://localhost:3000/`,
        changeOrigin: false,
      },
      '/getWeChatUrlScheme': {
        target: `http://localhost:3000/`,
        changeOrigin: false,
      }
    },
  },
  //快捷路径
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'),
      '@utils': path.resolve(__dirname, 'src/utils'),
      '@style': path.resolve(__dirname, 'src/assets/style'),
      '@comps': path.resolve(__dirname, 'src/components'),
      '@pages': path.resolve(__dirname, 'src/pages'),
    }
  },
  //css加载
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: '@import "@style/main.scss";'
      }
    }
  }
})
